/**
 * 
 */
package com.module.hq.ui.mono.inventory.widgets;

import java.awt.Dimension;

import com.dalonedrau.jogl.engine.GameApplet;
import com.dalonedrau.jogl.engine.JOGLErrorHandler;
import com.dalonedrau.jogl.opengl.sprite.BasicSpriteObject;
import com.dalonedrau.jogl.opengl.sprite.SpriteBase;
import com.dalonedrau.jogl.opengl.sprite.SpriteImageObject;
import com.dalonedrau.jogl.opengl.sprite.SpriteImageObjectFactory;
import com.dalonedrau.jogl.opengl.ui.GuiTextItemImpl;
import com.dalonedrau.watchable.Watchable;
import com.dalonedrau.watchable.Watcher;
import com.module.hq.ui.mono.borders.HQMonoInventoryBorder;
import com.rpg.base.flyweight.InventorySlot;

/**
 * @author Donald
 */
public class InventorySlotContainer extends GuiTextItemImpl implements Watcher {
	/** sprite for the inventory item. */
	private SpriteBase		item;
	/** the inventory slot has a specific size, 32px x 32px. */
	private Dimension		size	= new Dimension(32, 32);
	private InventorySlot	slot;
	/**
	 * Creates a new instance of {@link InventorySlotContainer}.
	 */
	private InventorySlotContainer() {
		super(null, null);
		super.setBorder(new HQMonoInventoryBorder());
		try {
			SpriteImageObject img =
					SpriteImageObjectFactory.getInstance().getImageByName(
							"hq_mono_stat_bar_left");
			item = new BasicSpriteObject();
			item.setImageRefId(img.getRefId());
			item.setWidth(img.getWidth());
			item.setHeight(img.getHeight());
			img = null;
		} catch (Exception ex) {
			JOGLErrorHandler.getInstance().fatalError(ex);
		}
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public Dimension getPreferredSize() {
		return size;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void prepareForRendering() throws Exception {
		super.prepareForRendering();
		if (slot != null
				&& slot.getIo() != null
				&& slot.isShow()) {

		}
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setPosition(final double x, final double y, final double z) {
		super.setPosition(x, y, z);
		if (item != null) {
			item.setPosition(
					super.getPosition().getX(),
					super.getPosition().getY(),
					super.getPosition().getZ()
					);
			item.clearFloatStore();
		}
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void watchUpdated(Watchable data) {
		if (slot.getIo() != null) {
			
		}
	}
}
